/*
 * Copyright (c) 2009, Eugen Stoian <stoian.e@gmail.com>
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 * http://www.fsf.org/licensing/licenses/lgpl.txt
 */
#include "Function.h"
#include <QVariant>
Function::Function(const QString& id,int arity, int dimension, Object* parent):Object(id,parent)
{
    _arguments.resize(arity);
    _components.resize(dimension);
    setProperty("dimension",QVariant(dimension));
    setProperty("arity",arity);
}

int Function::dimension() const {
    return _components.size();
}

int Function::arity() const {
    return _arguments.size();
}

ASTExpression* Function::operator[](int i){
    if((i<1)||(i>dimension()))
        return 0;
    return _components[i-1];
}

QString Function::signature() const {
    return id()+"_"+QString::number(arity());
}
